/**********************************************************************************************/
// dgt_PluginManager.h
//
// 
// Copyright Diamant Group 2007
/**********************************************************************************************/
#ifndef _dgtPLUGINMANAGER_H_
#define _dgtPLUGINMANAGER_H_

#include <wx/dynlib.h>
#include "DStudio.h"
#include "dgt_Plugin.h"
#include "dgt_SmartMacros.h"


/**********************************************************************************************/
struct Plugin
{
		wxString			m_LibName;			// name of library
		wxDynamicLibrary	*m_lib;				// instance of DLL
		wxString			m_Path;				// path to library
		dgt_Plugin_Ptr		m_plugin;			// plugin interface
};
WX_DECLARE_OBJARRAY( Plugin, PluginArray );



/**********************************************************************************************/
class dgt_PluginManager
{
	public://///////////////////////////////////////////////////////////////////////////////////

							dgt_PluginManager( void )		{};

							~dgt_PluginManager( void )		{};

	public://///////////////////////////////////////////////////////////////////////////////////

		void				LoadAll( void );

		void				set_Path( wxString inPath )		{ m_Path = inPath; }
		wxString			get_Path( void )				{ return m_Path; }

		void				set_CompPath( wxString inPath )	{ m_CompPath = inPath; }
		wxString			get_CompPath( void )			{ return m_CompPath; }

		unsigned			get_PluginCount();
		unsigned			get_PluginCount( PLUGIN_TYPE inType );

		dgt_Plugin_Ptr		get_Plugin( unsigned inNum );
		dgt_Plugin_Ptr		get_Plugin( PLUGIN_TYPE inType, unsigned inNum );

		void				Load( unsigned inNum );	
		void				Unload( unsigned inNum );
		bool				IsLoaded( unsigned inNum );
		
		wxString			get_PluginDllName( unsigned inNum );
		wxString			get_PluginDllName( PLUGIN_TYPE inType, unsigned inNum );

		dgt_Plugin_Ptr		get_PluginByLibName( wxString inName );

		long				get_Number( dgt_Plugin_Ptr inPlug );

		wxString			get_PluginTypeString( PLUGIN_TYPE inType );

	private:////////////////////////////////////////////////////////////////////////////////////

		wxArrayInt			ArrCat( wxArrayInt inArray1, wxArrayInt inArray2 );
		wxArrayInt			ArrCat( wxArrayInt inArray1, 
									wxArrayInt inArray2,
									wxArrayInt inArray3,
									wxArrayInt inArray4,
									wxArrayInt inArray5 );

		void				LoadDirectory( wxString inPath );

		wxString			m_Path;				// Path to plugin directory
		wxString			m_CompPath;			// Path to components directory

		PluginArray			m_Array;			// Plugins array

							// Arrays of numbers of plugins by types
		wxArrayInt			m_Logical, m_Memory, m_Operation, m_Trigger, m_CASynt, m_OASynt, m_Store, m_Out, m_Circuit;
};

#endif	// _dgtPLUGINMANAGER_H_

